package com.zbkj.front.controller;

import com.zbkj.common.request.*;
import com.zbkj.common.result.CommonResult;
import com.zbkj.service.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.Map;


@Slf4j
@RestController
@RequestMapping("api/front/ai")
@Api(tags = "ai试穿")
public class AiController {

    @Autowired
    private ProductService productService;


    @ApiOperation(value = "ai试穿--返回图片流")
    @RequestMapping(value = "/tryon", method = RequestMethod.POST)
    public File tryon(@RequestBody @Validated AiRequest aiRequest) {
        return productService.tryon(aiRequest);
    }


    @ApiOperation(value = "ai试穿--图生图")
    @RequestMapping(value = "/tryon/file", method = RequestMethod.POST)
    public CommonResult<Map> tryonFile(@RequestBody @Validated AiRequest aiRequest) {
        return CommonResult.success(productService.tryonFile(aiRequest));
    }


    @Deprecated
    @ApiOperation(value = "ai试穿--多图片合并接口，将多张图片合成为一张图片并返回腾讯云cos储存url")
    @RequestMapping(value = "/tryon/file/merge", method = RequestMethod.POST)
    public CommonResult<Map> tryonFileMerge(@RequestBody @Validated AiFileMergeRequest aiFileMergeRequest) {
        return CommonResult.success(productService.tryonFileMerge(aiFileMergeRequest));
    }


    @Deprecated
    @ApiOperation(value = "ai试穿--图生视频")
    @RequestMapping(value = "/tryon/video", method = RequestMethod.POST)
    public CommonResult<Map> tryonVideo(@RequestBody @Validated AiVideoRequest aiVideoRequest) {
        return CommonResult.success(productService.tryonVideo(aiVideoRequest));
    }


    @ApiOperation(value = "ai试穿--图生视频-云版本")
    @RequestMapping(value = "/vidu/image_to_video", method = RequestMethod.POST)
    public CommonResult<Map> viduImageToVideo(@RequestBody @Validated AiVideoRequest aiVideoRequest) {
        return CommonResult.success(productService.viduImageToVideo(aiVideoRequest));
    }


    @Deprecated
    @ApiOperation(value = "ai试穿--换脸-第三方模型")
    @RequestMapping(value = "/tryon/faceswap", method = RequestMethod.POST)
    public CommonResult<Map> tryonFaceswap(@RequestBody @Validated AiFaceswapRequest aiFaceswapRequest) {
        return CommonResult.success(productService.tryonFaceswap(aiFaceswapRequest));
    }


    @ApiOperation(value = "ai试穿--换脸增强版-第三方模型")
    @RequestMapping(value = "/tryon/faceswap/ultra", method = RequestMethod.POST)
    public CommonResult<Map> tryonFaceswapUltra(@RequestBody @Validated AiFaceswapRequest aiFaceswapRequest) {
        return CommonResult.success(productService.tryonFaceswapUltra(aiFaceswapRequest));
    }


    @ApiOperation(value = "ai试穿--换脸-本地模型")
    @RequestMapping(value = "/tryon/faceswap/facefusion", method = RequestMethod.POST)
    public CommonResult<Map> tryonFaceswapFacefusion(@RequestBody @Validated AiFacefusionRequest aiFacefusionRequest) {
        return CommonResult.success(productService.tryonFaceswapFacefusion(aiFacefusionRequest));
    }


    @ApiOperation(value = "ai试穿--背景图与透明背景图合成一张图片后，再生视频")
    @RequestMapping(value = "/tryon/faceswap/merge", method = RequestMethod.POST)
    public CommonResult<Map> tryonFaceswapMerge(@RequestBody @Validated AiFacefusionMergeRequest aiFacefusionMergeRequest) {
        return CommonResult.success(productService.tryonFaceswapMerge(aiFacefusionMergeRequest));
    }


//    @ApiOperation(value = "ai试穿--根据模特和分类查询蒙版地址")
//    @RequestMapping(value = "/tryon/faceswap/merge", method = RequestMethod.POST)
//    public CommonResult<Map> tryonFaceswapMerge(@RequestBody @Validated AiFacefusionMergeRequest aiFacefusionMergeRequest) {
//        return CommonResult.success(productService.tryonFaceswapMerge(aiFacefusionMergeRequest));
//    }

}



